import { lazy } from "react";
import {
    AppOutline,
    MessageOutline,
    TextOutline,
    UserOutline,
} from 'antd-mobile-icons'
import { Navigate, createBrowserRouter } from "react-router-dom";

// 引入一级路由
const Layout = lazy(() => import('../pages/Layout'))
const TickList = lazy(() => import('../pages/TickList'))
const Detail = lazy(() => import('../pages/Detail'))
const Parent = lazy(() => import('../pages/Parent'))
const Login = lazy(() => import('../pages/Login'))
const AddParent = lazy(() => import('../pages/AddParent'))
const Error = lazy(() => import('../pages/Error'))


// 引入二级路由
const Home = lazy(() => import('../pages/two/Home'))
const Message = lazy(() => import('../pages/two/Message'))
const Order = lazy(() => import('../pages/two/Order'))
const User = lazy(() => import('../pages/two/User'))


// 调用二级路由
export const layoutRouter = [
    {
        path: '/layout/home',
        element: <Home></Home>,
        title: '首页',
        icon: <AppOutline />
    },
    {
        path: '/layout/Order',
        element: <Order></Order>,
        title: '订单',
        icon: <TextOutline />
    },
    {
        path: '/layout/message',
        element: <Message></Message>,
        title: '消息',
        icon: <MessageOutline />
    },
    {
        path: '/layout/user',
        element: <User></User>,
        title: '用户',
        icon: <UserOutline />
    }
]

// 调用一级路由
const router = createBrowserRouter([
    {
        path: '/',
        element: <Navigate to='/layout/home'></Navigate>
    },
    {
        path: '/layout',
        element: <Layout></Layout>,
        children: layoutRouter
    },
    {
        path: '/addparent',
        element: <AddParent></AddParent>,
    },
       {
        path: '/parent/:id',
        element: <Parent></Parent>,
    },
        {
        path: '/ticklist',
        element: <TickList></TickList>,
    },
        {
        path: '/login',
        element: <Login></Login>,
    },
    {
        path: '/detail/:id',
        element: <Detail></Detail>,
    },
    {
        path: '*',
        element: <Error></Error>
    }
])
export default router